﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;

namespace Util
{
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
    public class AlgorithmVariationAttribute : Attribute
    {
        public static IEnumerable<MethodInfo> GetAlgorithmMethods(object o)
        {
            var list = new List<MethodInfo>();

            if (o == null)
            {
                return list.ToArray();
            }

            Type type = o.GetType();
            list.AddRange(
                type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)
                .Where(mi => IsDefined(mi, typeof (AlgorithmVariationAttribute))));

            return list.ToArray();
        }
    }
}
